package cinema.model;

import java.time.*;
import java.util.*;

public class Showtime {
    private Movie movie;
    private Theater theater;
    private LocalDateTime time;
    private double price;
    private boolean[][] sold; // true=已售

    public Showtime(Movie movie, Theater theater, LocalDateTime time, double price) {
        this.movie = movie;
        this.theater = theater;
        this.time = time;
        this.price = price;
        this.sold = new boolean[theater.getRows()][theater.getCols()];
    }

    public Movie getMovie() { return movie; }
    public Theater getTheater() { return theater; }
    public LocalDateTime getTime() { return time; }
    public double getPrice() { return price; }

    public boolean isSold(int row, int col) {
        return sold[row-1][col-1];
    }
    public void sellSeat(int row, int col) {
        sold[row-1][col-1] = true;
    }
    public void refundSeat(int row, int col) {
        sold[row-1][col-1] = false;
    }

    public void printSeatMap() {
        for (int r=1; r<=theater.getRows(); r++) {
            for (int c=1; c<=theater.getCols(); c++) {
                System.out.print(isSold(r,c)?"[X]":"[O]");
            }
            System.out.println();
        }
    }
}

